import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/AboutView.vue'),
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/dingtalk-callback',
      name: 'DingtalkCallback',
      component: () => import('../views/DingtalkCallback.vue'),
    },
    {
      path: '/gitee-callback',
      name: 'GiteeCallback',
      component: () => import('../views/GiteeCallback.vue'),
    },
    // 处理钉钉回调可能跳转到 /home/ 的情况
    {
      path: '/home/',
      name: 'HomeWithCallback',
      component: HomeView,
      props: (route) => ({ callbackParams: route.query }),
    }
  ],
})

export default router
